//
//  CourseStudyNoDataCell.m
//  ShowYork
//
//  Created by hxh on 2020/9/15.
//  Copyright © 2020 hxh. All rights reserved.
//

#import "LessonStudyNoDataCell.h"


@interface LessonStudyNoDataCell ()
@property (nonatomic,strong)UIImageView *noDataImgView;
@property (nonatomic,strong)UILabel *noDataLb;
@property (nonatomic,strong)UIButton *confirmBtn;
@end

@implementation LessonStudyNoDataCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setUI];
    }
    return self;
}
- (void)setUI{
    self.backgroundColor = RGBA(248, 248, 248, 1);
    
    self.noDataImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"course_noData_tag"]];
    [self.contentView addSubview:self.noDataImgView];
    
    [self.noDataImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.contentView).offset(76);
        make.centerX.mas_equalTo(self.contentView);
    }];
    
    self.noDataLb = [[UILabel alloc]init];
    self.noDataLb.textColor = C153;
    self.noDataLb.font = font(12);
    [self.contentView addSubview:self.noDataLb];
    
    [self.noDataLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.noDataImgView.mas_bottom).offset(8);
        make.centerX.mas_equalTo(self.noDataImgView);
    }];
    
    self.confirmBtn = [[UIButton alloc]init];
    [self.confirmBtn setTitle:@"去选课" forState:UIControlStateNormal];
    [self.confirmBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    self.confirmBtn.titleLabel.font = font(14);
    self.confirmBtn.layer.cornerRadius = 17;
    self.confirmBtn.layer.masksToBounds = YES;
    self.confirmBtn.backgroundColor = [RPAppManager themColor];
    [self.confirmBtn addTarget:self action:@selector(confirmMethod) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:self.confirmBtn];
    
    [self.confirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.noDataLb.mas_bottom).offset(48);
        make.height.mas_equalTo(34).priorityHigh();
        make.width.mas_equalTo(90);
        make.bottom.mas_equalTo(self.contentView);
        make.centerX.mas_equalTo(self.contentView);
    }];
}

+(instancetype)cellWithTableView:(UITableView *)tableView{
    NSString *ID = @"LessonStudyNoDataCell";
    LessonStudyNoDataCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell) {
        cell = [[LessonStudyNoDataCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return cell;
}

- (void)confirmMethod{
    if (self.delegate && [self.delegate respondsToSelector:@selector(choiceCourseStudy)]) {
        [self.delegate choiceCourseStudy];
    }
}

- (void)setNoMessage:(NSString *)message stauts:(BOOL)status{
    self.noDataLb.text = message;
    self.confirmBtn.hidden = status;
}

@end
